﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;

using ProjectBase.Core;

namespace $safeprojectname$
{
    /// <summary>
    ///     html &lt;OPTGROUP&gt; element.
    ///     Should (can) be used only for a Select element
    /// </summary>
    public class OptionGroup : ContentControl<ICoreModel, Option, OptionGroup>, ISelectChild
    {
        #region members
        Literal _literal = new Literal();
        #endregion members

        #region constructor
        public OptionGroup(string text = null, bool doLocalize = false, string cssClassName = null)
            : base(cssClassName)
        {
            Controls.Add(_literal);
            _literal.SetText(text, doLocalize);
        }
        #endregion constructor

        #region Set
        public virtual OptionGroup SetLabel(string label)
        {
            Label = label;
            return this;
        }
        public virtual OptionGroup SetDisabled(bool isDisabled)
        {
            if (isDisabled)
            {
                Attributes.Remove(Attr.Disabled);
            }
            else
            {
                Disabled = Attr.Disabled;
            }
            return this;
        }
        #endregion Set

        #region properties

        protected override string TagName
        {
            get { return Tag.OptionGroup; }
        }

        public virtual string Label
        {
            get { return GetAttribute(Attr.Label); }
            set { SetAttribute(Attr.Label, value); }
        }

        public virtual string Disabled
        {
            get { return GetAttribute(Attr.Disabled); }
            set { SetAttribute(Attr.Disabled, value); }
        }
        #endregion properties
    }
}